package com.yumingjiang.common.util;

import com.yumingjiang.common.model.Result;

/**
 * @description:
 * @author: John
 * @version: ResultUtil.java, v1.0 2024年12月31日 20:32
 */
public class ResultUtil {

    public static <T>Result<T> buildSuccess(T data){
        Result<T> result = new Result<>();
        result.setSuccess(true);
        result.setCode(200);
        result.setMessage("success");
        result.setData(data);
        return result;
    }

    public static Result buildError(){
        Result result = new Result<>();
        result.setSuccess(false);
        result.setCode(-1);
        result.setMessage("system error.");
        return result;
    }
    public static Result buildError(String errmsg){
        Result result = new Result<>();
        result.setSuccess(false);
        result.setCode(-1);
        result.setMessage(errmsg);
        return result;
    }

}